<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<%@ page import="com.onlineauction.helpers.Constants"%>
<%@ page import="com.onlineauction.entities.Item"%>
<%@ page import="com.onlineauction.entities.Bid"%>
<%@ page import="com.onlineauction.entities.Auction"%>
<%@ page import="com.onlineauction.helpers.Constants.Category" %>
<%@ page import="com.onlineauction.beans.MakeBidBean"%>
<%@ page import="com.onlineauction.beans.MakeBidBean.MakeBidDataRow"%>
<%@ page import="com.onlineauction.helpers.Constants.Usertype"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!-- 
	<link rel="stylesheet" href="style.css" />  
-->
<title>Confirm Bid</title>
<link rel="stylesheet"
	href="http://code.jquery.com/ui/1.10.2/themes/smoothness/jquery-ui.css" />
<link rel="stylesheet" href="style.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<script src="timepicker_addon.js"></script>
</head>


<jsp:useBean id="confirmBidBean"
	class="com.onlineauction.beans.ConfirmBidBean" scope="request" />

<%
	//redirect to Home if session is not set (user is not logged in yet)
	String username = (String) session.getAttribute(Constants.USERNAME);
	if (username == null) {
		request.getRequestDispatcher("/Home").forward(request, response);
	} else {
		confirmBidBean.setUsername(username);
		String itemIDString = request.getParameter(Constants.ITEM_ID);
		confirmBidBean.setItemIDString(itemIDString);
	}
	
%>


<body>
	<div class="wrapper">
		<div id="Content">
			<div id="Header">
				<H1>Place Bid on Item</H1>
				<div id="LogOutButtonDiv" align="left">
					<a href="/Home">Home</a> <a href="LogoutAccount">Logout</a>
				</div>
			</div>
			<hr />
			<div id="MainContent">
				<h3>Item Details:</h3>
				<table>
					<tr>
						<th>Item Name</th>
						<th>Category</th>
						<th>Seller</th>
						<th>Base Price</th>
						<th>Best Price</th>
						<th>Auction End Time</th>
					</tr>
					<tr>
						<td><%=confirmBidBean.getItemName()%></td>
						<td><%=confirmBidBean.getCategory()%></td>
						<td><%=confirmBidBean.getOwner()%></td>
						<td><%=confirmBidBean.getBasePrice()%></td>
						<% if (confirmBidBean.getAuctionID() == -1) { %>							
						<td><%=confirmBidBean.getBestPrice()%></td>
						<% } else { %>
						<td><button><a href="/ViewAuction?<%=Constants.AUCTION_ID%>=<%=confirmBidBean.getAuctionID()%>"><%=confirmBidBean.getBestPrice()%></a></button></td>
						<% } %>							
						<td><%=confirmBidBean.getEndTime()%></td>
					</tr>
				</table>

				<%
				    if (!confirmBidBean.isHavingActiveAuction()) {
				%>
				<h3>SORRY! There are no active auction on this item at this
					time.</h3>
				<%
				    } else {				    					    				    					    
				%>
				<h3>Make a bid on this item:</h3>
				<form action="ConfirmBid" method="post">
				    <input type="hidden" name="<%=Constants.AUCTION_ID%>" value="<%=confirmBidBean.getAuctionID()%>">
				    <input type="hidden" name="<%=Constants.ITEM_ID%>" value="<%=confirmBidBean.getItemID()%>">
					<table>
						<tr>
							<td align="right">Your bid price: <input align="right" type="text"
								name="<%=Constants.BID_PRICE%>" value="<%=confirmBidBean.getNextBidPrice()%>"/></td>
							<td><input type="submit" value="Confirm!" /></td>
						</tr>						
					</table>
				</form>
				<%
					}
				%>
				<%
					String message = (String) request.getAttribute(Constants.MESSAGE);
					if (message != null && message.length() != 0) {
						out.println(message);
					}
				%>				
			<!-- end MainContent -->
		</div>
		<iframe src="<%="/review?reviewee="+confirmBidBean.getOwner() %>" width="100%" height="500px"></iframe>
		<!-- end Content -->
	</div>
	<!-- end wrapper -->
</body>
</html>

